<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <!-- 
    传统url 传参
    fetch 方法第一个参数是接口地址
    第二个参数是一个对象 对象里面是发送请求的参数信息

   -->
  <script>
    fetch('http://127.0.0.1:3000/books?id=1', {
      method: 'get'
      // method 请求方式
    }).then((data) => {
      return data.text()
    }).then((data) => {
      console.log(data);
    })

    // restFull 接口规范
    fetch('http://127.0.0.1:3000/books/1', {
      method: 'get'
    }).then((data) => {
      return data.text()
    }).then((data) => {
      console.log(data);
    })

    //  delete 请求
    fetch('http://127.0.0.1:3000/books/1', {
      method: 'delete'
    }).then((data) => {
      return data.text()
    }).then((data) => {
      console.log(data);
    })
  </script>
</body>

</html>